<?
    /**
     * PrincipioLab
     *
     * @package    PrincipioLab
     */

    /**
     * PrincipioLab_TCollection
     *
     * @package    PrincipioLab
     */
    trait PrincipioLab_TCollection
    {
        /**
         * @param null|array $values
         *
         * @throws RuntimeException
         */
        public static function fromArray(array $values = null) { throw new RuntimeException("Collection error: method 'fromArray' must be overriden."); }


        /**
         * @param null|PrincipioLab_IComparator $comparator
         *
         * @return PrincipioLab_LinkedList
         */
        public static function getLinkedList(PrincipioLab_IComparator $comparator = null) { return new PrincipioLab_LinkedList($comparator); }


        /**
         * @param null|array                    $values
         * @param null|PrincipioLab_IComparator $comparator
         *
         * @return PrincipioLab_LinkedList
         */
        public static function makeCollection(array $values = null, PrincipioLab_IComparator $comparator = null)
        {
            $collection = static::getLinkedList($comparator);

            if (!is_null($values))
            {
                foreach ($values as $value)
                    $collection->addItem(static::fromArray($value));
            };

            return $collection;
        }
    }
?>